package demo.server.socket;

import core.threadpool.PoolManager;

public class PoolMonitor extends Thread{
	private PoolManager poolManager;
	private long delay;
	private boolean isStop = false;
	
	public PoolMonitor (PoolManager poolManager, long delay){
		this.poolManager = poolManager;
		this.delay = delay;
	}
	
	public void shutdown(){
		this.isStop = true;
	}
	
	@Override
	public void run() {
		while(!isStop){
			String outMonitor = String.format("{monitor} coreSize: %d | maxSize: %d | currentSize: %d | taskSize: %d", poolManager.getCoreSize(), poolManager.getMaxSize(), poolManager.getCurrentPool(), poolManager.getCurrentTask());
			System.out.println(outMonitor);
			try {
				Thread.sleep(delay);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
